﻿@using Orchard.Tokens
@{
    Script.Require("jQuery");
    Script.Include("TokenHelp.js");
    Style.Include("orchard-tokenhelp.css");
    
    var tokens = Model.Tokens as IEnumerable<TokenTypeDescriptor>;
    if (tokens == null)
    {
        tokens = Html.Resolve<ITokenManager>().Describe((IEnumerable<string>)Model.Targets);
    }
}
<table class="token-help items">
    <thead>
        <tr>
            <th>@T("Name")</th>
            <th>@T("Token")</th>
            <th>@T("Description")</th>
        </tr>
    </thead>
    <tbody>
    @foreach (var tokenType in tokens.OrderBy(d => d.Name.ToString()))
    {
        <tr class="token-type">
            <td class="token-typename">@tokenType.Name</td>
            <td>&nbsp;</td>
            <td class="token-desc">@tokenType.Description</td>
        </tr>
        foreach (var token in tokenType.Tokens.OrderBy(t => t.Name.ToString()))
        {
        <tr class="token-subtoken token-collapsed">
            <td class="token-name">@token.Name</td>
            <td class="token-token">{@token.Target.@token.Token}</td>
            <td class="token-desc">@token.Description</td>
        </tr>
        }
    }
    </tbody>
</table>
